package com.pcitc.app.model;

import com.pcitc.app.model.BaseObject;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import java.io.Serializable;

@Entity
@Table(name="TBL_CRUDE_CATEGORY",schema="XZGD")
public class TblCrudeCategory extends BaseObject implements Serializable {
    private String categoryCode;
    private String categoryName;
    private String parentId;
    private Set<TblCrude> tblCrudes = new HashSet<TblCrude>(0);

    @Id  @GeneratedValue(strategy = GenerationType.AUTO)    
    public String getCategoryCode() {
        return this.categoryCode;
    }
    
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
    
    @Column(name="CATEGORY_NAME", length=80)
    public String getCategoryName() {
        return this.categoryName;
    }
    
    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
    
    @Column(name="PARENT_ID", length=20)
    public String getParentId() {
        return this.parentId;
    }
    
    public void setParentId(String parentId) {
        this.parentId = parentId;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="tblCrudeCategory")
    public Set<TblCrude> getTblCrudes() {
        return this.tblCrudes;
    }
    
    public void setTblCrudes(Set<TblCrude> tblCrudes) {
        this.tblCrudes = tblCrudes;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TblCrudeCategory pojo = (TblCrudeCategory) o;

        if (categoryName != null ? !categoryName.equals(pojo.categoryName) : pojo.categoryName != null) return false;
        if (parentId != null ? !parentId.equals(pojo.parentId) : pojo.parentId != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (categoryName != null ? categoryName.hashCode() : 0);
        result = 31 * result + (parentId != null ? parentId.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("categoryCode").append("='").append(getCategoryCode()).append("', ");
        sb.append("categoryName").append("='").append(getCategoryName()).append("', ");
        sb.append("parentId").append("='").append(getParentId()).append("', ");
        
        sb.append("]");
      
        return sb.toString();
    }

}
